package core.redeNeural;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.List;

public class Serializador {

	@SuppressWarnings("unchecked")
	public static List<String> recuperarPopulacao(String fileName){
		
		try{
			FileInputStream fis = new FileInputStream(fileName);
			ObjectInputStream in = new ObjectInputStream(fis);
			return (List<String>) in.readObject();
		}catch(IOException e){
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

		return null;
	}

	public static void armazenarPopulacao(String fileName, List<String> populacao){

		try {
			FileOutputStream fos = new FileOutputStream(fileName);
			ObjectOutputStream out = new ObjectOutputStream(fos);
			out.writeObject(populacao);
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}	

	}


}
